home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Interfaces & Libraries / Interfaces / PInterfaces / Components.p < prev    next >
Encoding:
Text File  |  1995-07-06  |  11.1 KB  |  336 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        Components.p
  3.  
  4.      Contains:    Component Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. }
  19.  
  20. {$IFC UNDEFINED UsingIncludes}
  21. {$SETC UsingIncludes := 0}
  22. {$ENDC}
  23.  
  24. {$IFC NOT UsingIncludes}
  25.  UNIT Components;
  26.  INTERFACE
  27. {$ENDC}
  28.  
  29. {$IFC UNDEFINED __COMPONENTS__}
  30. {$SETC __COMPONENTS__ := 1}
  31.  
  32. {$I+}
  33. {$SETC ComponentsIncludes := UsingIncludes}
  34. {$SETC UsingIncludes := 1}
  35.  
  36.  
  37. {$IFC UNDEFINED __TYPES__}
  38. {$I Types.p}
  39. {$ENDC}
  40. {    ConditionalMacros.p                                            }
  41.  
  42. {$IFC UNDEFINED __MIXEDMODE__}
  43. {$I MixedMode.p}
  44. {$ENDC}
  45.  
  46. {$PUSH}
  47. {$ALIGN MAC68K}
  48. {$LibExport+}
  49.  
  50. CONST
  51.     kAppleManufacturer            = 'appl';                        { Apple supplied components }
  52.     kComponentResourceType        = 'thng';
  53.  
  54.     kAnyComponentType            = 0;
  55.     kAnyComponentSubType        = 0;
  56.     kAnyComponentManufacturer    = 0;
  57.     kAnyComponentFlagsMask        = 0;
  58.  
  59.     cmpWantsRegisterMessage        = 1 * (2**(31));
  60.  
  61.     kComponentOpenSelect        = -1;                            { ComponentInstance for this open }
  62.     kComponentCloseSelect        = -2;                            { ComponentInstance for this close }
  63.     kComponentCanDoSelect        = -3;                            { selector # being queried }
  64.     kComponentVersionSelect        = -4;                            { no params }
  65.     kComponentRegisterSelect    = -5;                            { no params }
  66.     kComponentTargetSelect        = -6;                            { ComponentInstance for top of call chain }
  67.     kComponentUnregisterSelect    = -7;                            { no params }
  68.  
  69. { Component Resource Extension flags }
  70.     componentDoAutoVersion        = 0+(1 * (2**(0)));
  71.     componentWantsUnregister    = 0+(1 * (2**(1)));
  72.     componentAutoVersionIncludeFlags = 0+(1 * (2**(2)));
  73.     componentHasMultiplePlatforms = 0+(1 * (2**(3)));
  74.  
  75. { Set Default Component flags }
  76.     defaultComponentIdentical    = 0;
  77.     defaultComponentAnyFlags    = 1;
  78.     defaultComponentAnyManufacturer = 2;
  79.     defaultComponentAnySubType    = 4;
  80.     defaultComponentAnyFlagsAnyManufacturer = 0+(defaultComponentAnyFlags + defaultComponentAnyManufacturer);
  81.     defaultComponentAnyFlagsAnyManufacturerAnySubType = 0+(defaultComponentAnyFlags + defaultComponentAnyManufacturer + defaultComponentAnySubType);
  82.  
  83. { RegisterComponentResource flags }
  84.     registerComponentGlobal        = 1;
  85.     registerComponentNoDuplicates = 2;
  86.     registerComponentAfterExisting = 4;
  87.  
  88.  
  89. TYPE
  90.     ComponentDescription = RECORD
  91.         componentType:            OSType;                                    { A unique 4-byte code indentifying the command set }
  92.         componentSubType:        OSType;                                    { Particular flavor of this instance }
  93.         componentManufacturer:    OSType;                                    { Vendor indentification }
  94.         componentFlags:            LONGINT;                                { 8 each for Component,Type,SubType,Manuf/revision }
  95.         componentFlagsMask:        LONGINT;                                { Mask for specifying which flags to consider in search, zero during registration }
  96.     END;
  97.  
  98.     ResourceSpec = RECORD
  99.         resType:                OSType;                                    { 4-byte code  }
  100.         resID:                    INTEGER;
  101.     END;
  102.  
  103.     ComponentResource = RECORD
  104.         cd:                        ComponentDescription;                    { Registration parameters }
  105.         component:                ResourceSpec;                            { resource where Component code is found }
  106.         componentName:            ResourceSpec;                            { name string resource }
  107.         componentInfo:            ResourceSpec;                            { info string resource }
  108.         componentIcon:            ResourceSpec;                            { icon resource }
  109.     END;
  110.  
  111.     ComponentResourcePtr = ^ComponentResource;
  112.     ComponentResourceHandle = ^ComponentResourcePtr;
  113.  
  114.     ComponentPlatformInfo = RECORD
  115.         componentFlags:            LONGINT;                                { flags of Component }
  116.         component:                ResourceSpec;                            { resource where Component code is found }
  117.         platformType:            INTEGER;                                { gestaltSysArchitecture result }
  118.     END;
  119.  
  120.     ComponentResourceExtension = RECORD
  121.         componentVersion:        LONGINT;                                { version of Component }
  122.         componentRegisterFlags:    LONGINT;                                { flags for registration }
  123.         componentIconFamily:    INTEGER;                                { resource id of Icon Family }
  124.     END;
  125.  
  126.     ComponentPlatformInfoArray = RECORD
  127.         count:                    LONGINT;
  128.         platformArray:            ARRAY [0..0] OF ComponentPlatformInfo;
  129.     END;
  130.  
  131.     ExtComponentResource = RECORD
  132.         cd:                        ComponentDescription;                    { registration parameters }
  133.         component:                ResourceSpec;                            { resource where Component code is found }
  134.         componentName:            ResourceSpec;                            { name string resource }
  135.         componentInfo:            ResourceSpec;                            { info string resource }
  136.         componentIcon:            ResourceSpec;                            { icon resource }
  137.         componentVersion:        LONGINT;                                { version of Component }
  138.         componentRegisterFlags:    LONGINT;                                { flags for registration }
  139.         componentIconFamily:    INTEGER;                                { resource id of Icon Family }
  140.         count:                    LONGINT;                                { elements in platformArray }
  141.         platformArray:            ARRAY [0..0] OF ComponentPlatformInfo;
  142.     END;
  143.  
  144.     ComponentParameters = PACKED RECORD
  145.         flags:                    CHAR;                                    { call modifiers: sync/async, deferred, immed, etc }
  146.         paramSize:                CHAR;                                    { size in bytes of actual parameters passed to this call }
  147.         what:                    INTEGER;                                { routine selector, negative for Component management calls }
  148.         params:                    ARRAY [0..0] OF LONGINT;                { actual parameters for the indicated routine }
  149.     END;
  150.  
  151.     ComponentRecord = RECORD
  152.         data:                    ARRAY [0..0] OF LONGINT;
  153.     END;
  154.  
  155.     Component = ^ComponentRecord;
  156.  
  157.     ComponentInstanceRecord = RECORD
  158.         data:                    ARRAY [0..0] OF LONGINT;
  159.     END;
  160.  
  161.     ComponentInstance = ^ComponentInstanceRecord;
  162.  
  163.     ComponentResult = LONGINT;
  164.  
  165.     ComponentRoutineProcPtr = ProcPtr;  { FUNCTION ComponentRoutine(VAR cp: ComponentParameters; componentStorage: Handle): ComponentResult; }
  166.     ComponentRoutineUPP = UniversalProcPtr;
  167.  
  168. CONST
  169.     uppComponentRoutineProcInfo = $000003F0; { FUNCTION (4 byte param, 4 byte param): 4 byte result; }
  170.  
  171. FUNCTION NewComponentRoutineProc(userRoutine: ComponentRoutineProcPtr): ComponentRoutineUPP;
  172.     {$IFC NOT GENERATINGCFM }
  173.     INLINE $2E9F;
  174.     {$ENDC}
  175.  
  176. FUNCTION CallComponentRoutineProc(VAR cp: ComponentParameters; componentStorage: Handle; userRoutine: ComponentRoutineUPP): ComponentResult;
  177.     {$IFC NOT GENERATINGCFM}
  178.     INLINE $205F, $4E90;
  179.     {$ENDC}
  180.     
  181. TYPE
  182.     ComponentRoutine = ComponentRoutineUPP;
  183.  
  184. {
  185.     The parameter list for each ComponentFunction is unique. It is 
  186.     therefore up to users to create the appropriate procInfo for their 
  187.     own ComponentFunctions where necessary.
  188. }
  189.     ComponentFunctionUPP = UniversalProcPtr;
  190.  
  191.  
  192. FUNCTION RegisterComponent(VAR cd: ComponentDescription; componentEntryPoint: ComponentRoutineUPP; global: INTEGER; componentName: Handle; componentInfo: Handle; componentIcon: Handle): Component;
  193.     {$IFC NOT GENERATINGCFM}
  194.     INLINE $7001, $A82A;
  195.     {$ENDC}
  196. FUNCTION RegisterComponentResource(tr: ComponentResourceHandle; global: INTEGER): Component;
  197.     {$IFC NOT GENERATINGCFM}
  198.     INLINE $7012, $A82A;
  199.     {$ENDC}
  200. FUNCTION UnregisterComponent(aComponent: Component): OSErr;
  201.     {$IFC NOT GENERATINGCFM}
  202.     INLINE $7002, $A82A;
  203.     {$ENDC}
  204. FUNCTION FindNextComponent(aComponent: Component; VAR looking: ComponentDescription): Component;
  205.     {$IFC NOT GENERATINGCFM}
  206.     INLINE $7004, $A82A;
  207.     {$ENDC}
  208. FUNCTION CountComponents(VAR looking: ComponentDescription): LONGINT;
  209.     {$IFC NOT GENERATINGCFM}
  210.     INLINE $7003, $A82A;
  211.     {$ENDC}
  212. FUNCTION GetComponentInfo(aComponent: Component; VAR cd: ComponentDescription; componentName: Handle; componentInfo: Handle; componentIcon: Handle): OSErr;
  213.     {$IFC NOT GENERATINGCFM}
  214.     INLINE $7005, $A82A;
  215.     {$ENDC}
  216. FUNCTION GetComponentListModSeed: LONGINT;
  217.     {$IFC NOT GENERATINGCFM}
  218.     INLINE $7006, $A82A;
  219.     {$ENDC}
  220. { Component Instance Allocation and dispatch routines }
  221. FUNCTION OpenComponent(aComponent: Component): ComponentInstance;
  222.     {$IFC NOT GENERATINGCFM}
  223.     INLINE $7007, $A82A;
  224.     {$ENDC}
  225. FUNCTION CloseComponent(aComponentInstance: ComponentInstance): OSErr;
  226.     {$IFC NOT GENERATINGCFM}
  227.     INLINE $7008, $A82A;
  228.     {$ENDC}
  229. FUNCTION GetComponentInstanceError(aComponentInstance: ComponentInstance): OSErr;
  230.     {$IFC NOT GENERATINGCFM}
  231.     INLINE $700A, $A82A;
  232.     {$ENDC}
  233. { Direct calls to the Components }
  234. FUNCTION ComponentFunctionImplemented(ci: ComponentInstance; ftnNumber: INTEGER): LONGINT;
  235.     {$IFC NOT GENERATINGCFM}
  236.     INLINE $2F3C, $2, $FFFD, $7000, $A82A;
  237.     {$ENDC}
  238. FUNCTION GetComponentVersion(ci: ComponentInstance): LONGINT;
  239.     {$IFC NOT GENERATINGCFM}
  240.     INLINE $2F3C, $0, $FFFC, $7000, $A82A;
  241.     {$ENDC}
  242. FUNCTION ComponentSetTarget(ci: ComponentInstance; target: ComponentInstance): LONGINT;
  243.     {$IFC NOT GENERATINGCFM}
  244.     INLINE $2F3C, $4, $FFFA, $7000, $A82A;
  245.     {$ENDC}
  246. { Component Management routines }
  247. PROCEDURE SetComponentInstanceError(aComponentInstance: ComponentInstance; theError: OSErr);
  248.     {$IFC NOT GENERATINGCFM}
  249.     INLINE $700B, $A82A;
  250.     {$ENDC}
  251. FUNCTION GetComponentRefcon(aComponent: Component): LONGINT;
  252.     {$IFC NOT GENERATINGCFM}
  253.     INLINE $7010, $A82A;
  254.     {$ENDC}
  255. PROCEDURE SetComponentRefcon(aComponent: Component; theRefcon: LONGINT);
  256.     {$IFC NOT GENERATINGCFM}
  257.     INLINE $7011, $A82A;
  258.     {$ENDC}
  259. FUNCTION OpenComponentResFile(aComponent: Component): INTEGER;
  260.     {$IFC NOT GENERATINGCFM}
  261.     INLINE $7015, $A82A;
  262.     {$ENDC}
  263. FUNCTION CloseComponentResFile(refnum: INTEGER): OSErr;
  264.     {$IFC NOT GENERATINGCFM}
  265.     INLINE $7018, $A82A;
  266.     {$ENDC}
  267. { Component Instance Management routines }
  268. FUNCTION GetComponentInstanceStorage(aComponentInstance: ComponentInstance): Handle;
  269.     {$IFC NOT GENERATINGCFM}
  270.     INLINE $700C, $A82A;
  271.     {$ENDC}
  272. PROCEDURE SetComponentInstanceStorage(aComponentInstance: ComponentInstance; theStorage: Handle);
  273.     {$IFC NOT GENERATINGCFM}
  274.     INLINE $700D, $A82A;
  275.     {$ENDC}
  276. FUNCTION GetComponentInstanceA5(aComponentInstance: ComponentInstance): LONGINT;
  277.     {$IFC NOT GENERATINGCFM}
  278.     INLINE $700E, $A82A;
  279.     {$ENDC}
  280. PROCEDURE SetComponentInstanceA5(aComponentInstance: ComponentInstance; theA5: LONGINT);
  281.     {$IFC NOT GENERATINGCFM}
  282.     INLINE $700F, $A82A;
  283.     {$ENDC}
  284. FUNCTION CountComponentInstances(aComponent: Component): LONGINT;
  285.     {$IFC NOT GENERATINGCFM}
  286.     INLINE $7013, $A82A;
  287.     {$ENDC}
  288. { Useful helper routines for convenient method dispatching }
  289. FUNCTION CallComponentFunction(VAR params: ComponentParameters; func: ComponentFunctionUPP): LONGINT;
  290.     {$IFC NOT GENERATINGCFM}
  291.     INLINE $70FF, $A82A;
  292.     {$ENDC}
  293. FUNCTION CallComponentFunctionWithStorage(storage: Handle; VAR params: ComponentParameters; func: ComponentFunctionUPP): LONGINT;
  294.     {$IFC NOT GENERATINGCFM}
  295.     INLINE $70FF, $A82A;
  296.     {$ENDC}
  297. FUNCTION DelegateComponentCall(VAR originalParams: ComponentParameters; ci: ComponentInstance): LONGINT;
  298.     {$IFC NOT GENERATINGCFM}
  299.     INLINE $7024, $A82A;
  300.     {$ENDC}
  301. FUNCTION SetDefaultComponent(aComponent: Component; flags: INTEGER): OSErr;
  302.     {$IFC NOT GENERATINGCFM}
  303.     INLINE $701E, $A82A;
  304.     {$ENDC}
  305. FUNCTION OpenDefaultComponent(componentType: OSType; componentSubType: OSType): ComponentInstance;
  306.     {$IFC NOT GENERATINGCFM}
  307.     INLINE $7021, $A82A;
  308.     {$ENDC}
  309. FUNCTION CaptureComponent(capturedComponent: Component; capturingComponent: Component): Component;
  310.     {$IFC NOT GENERATINGCFM}
  311.     INLINE $701C, $A82A;
  312.     {$ENDC}
  313. FUNCTION UncaptureComponent(aComponent: Component): OSErr;
  314.     {$IFC NOT GENERATINGCFM}
  315.     INLINE $701D, $A82A;
  316.     {$ENDC}
  317. FUNCTION RegisterComponentResourceFile(resRefNum: INTEGER; global: INTEGER): LONGINT;
  318.     {$IFC NOT GENERATINGCFM}
  319.     INLINE $7014, $A82A;
  320.     {$ENDC}
  321. FUNCTION GetComponentIconSuite(aComponent: Component; VAR iconSuite: Handle): OSErr;
  322.     {$IFC NOT GENERATINGCFM}
  323.     INLINE $7029, $A82A;
  324.     {$ENDC}
  325.  
  326. {$ALIGN RESET}
  327. {$POP}
  328.  
  329. {$SETC UsingIncludes := ComponentsIncludes}
  330.  
  331. {$ENDC} {__COMPONENTS__}
  332.  
  333. {$IFC NOT UsingIncludes}
  334.  END.
  335. {$ENDC}
  336.